<?php

declare(strict_types=1);

namespace App\Model;



use Carbon\Carbon;
use Hyperf\Database\Model\Relations\HasMany;

/**
 * @property int $id 
 * @property string $platform 平台
 * @property string $classify 小说分类
 * @property string $author 作者
 * @property string $name 小说名称
 * @property string $url 小说链接
 * @property string $brief_introduction 小说简介
 * @property string $img 小说图片
 * @property string $overall_novel 小说完整度: 1.完结 2.连载中
 * @property int $status 状态: 0.启用 1.禁用
 * @property Carbon $created_at 创建时间
 * @property Carbon $updated_at 更新时间
 * @property string $deleted_at 删除时间
 * @property string $number_words 小说字数
 * @property int $created_by 创建者
 * @property int $updated_by 修改人
 */
class Novel extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'novel';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'platform', 'classify', 'author', 'name', 'url', 'brief_introduction', 'img', 'overall_novel', 'status', 'created_at', 'updated_at', 'deleted_at', 'number_words', 'created_by', 'updated_by'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'created_by' => 'integer', 'updated_by' => 'integer'];

    /**
     * 获取小说全部章节
     * @return HasMany
     */
    public function getNovelChapterLists(): HasMany
    {
        return $this->hasMany(NovelChapter::class,'novel_id','id');
    }
}
